/**
 * 轻型Js类库
 * @author taotao
 * @email <544828662@qq.com>
 */
var CJL= (function(){
    return new Base();
});
function Base(){
	this.post = function(url,params,callback){
		alert("Cjl.post");
		$.post(url,params, function(json){
			var obj;
			if(typeof(json) == 'string') {
				obj = JSON.parse(json);
			} else {
				obj = json;
			}
			
			if(obj.code == 401){
				document.location = "/mobile/login.html";	
			}else if(obj.code == 0){
				callback(obj.body);
			}else{
				alert(obj.msg);
			}
		});
	};

	this.get = function(url, params, callback){
		alert("Cjl.get");
		$.get(url, params, function(json){
			var obj;
			if(typeof(json) == 'string') {
				obj = JSON.parse(json);
			} else {
				obj = json;
			}
			if(obj.code == 401){
				document.location = "/mobile/login.html";	
			} else if(obj.code == 0) {
				callback(obj.body);
			} else {
				alert(obj.msg);
			}
		});
	};
	
	this.requestData = function(name){
		alert("Cjl.requestData");
		var strHref = window.location.href;
		var pos = strHref.indexOf("?");
		var strRight = strHref.substr(pos + 1);
		var arrayTmp = strRight.split("&");
		for(var i=0;i<arrayTmp.length;i++){
			var tmp = arrayTmp[i].split("=");
			if(tmp[0]==name){
				return tmp[1];
			}
		}
	};
};